﻿using AutoMapper;
using Business.ReadAPI.Application.Products;
using Common.Domain;
using Common.Infrastructure.Repository;
using Common.Services;
using MediatR;

namespace Business.ReadAPI.Application.Breeds
{
    public class BreedQueryRequestHandler : IRequestHandler<BreedQueryRequestModel, APIResult>
    {
        private IBaseRepository<Breed> breedRepository;
        private readonly IMapper mapper;
        public BreedQueryRequestHandler(IBaseRepository<Breed> breedRepository, IMapper mapper)
        {
            this.breedRepository = breedRepository;
            this.mapper = mapper;
        }
        public Task<APIResult> Handle(BreedQueryRequestModel request, CancellationToken cancellationToken)
        {
            APIResult result = new APIResult();
            result.Code = EnumCode.SearchSuccess;
            result.Msg = "查询成功";

            var list = breedRepository.GetAll().FirstOrDefault();
            result.Data = list;

            return Task.FromResult(result);
        }
    }
    public class BreedQueryRequestModel:IRequest<APIResult>
    {
    }
    public class BreedQueryResponseModel
    {
        public int Id { get; set; }
        public string ProductCode { get; set; }
        public string Variety { get; set; }
        public string Source { get; set; }
        public int FeedingDays { get; set; }
        public string FeedingBrand { get; set; }
        public string FeedingName { get; set; }
        public DateTime SaleDate { get; set; }
        public string Creator { get; set; }
        public DateTime CreateTime { get; set; }
    }
}
